<extend name="Common:common"/>
<block name="main">

    <div class="main-content">
        <div class="breadcrumbs" id="breadcrumbs">
            <script type="text/javascript">
                try {
                    ace.settings.check('breadcrumbs', 'fixed')
                } catch (e) {
                }
            </script>

            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="#"> 云系统管理平台</a>
                </li>

                <li>
                    <a href="#">权限管理</a>
                </li>
                <li class="active">权限列表</li>
            </ul>
            <!-- .breadcrumb -->

            <div class="nav-search" id="nav-search">
                <a href="{:U('AdminNode/createnode')}" class="btn btn-xs btn-primary">添加权限</a>
            </div>
            <!-- #nav-search -->
        </div>

        <div class="page-content">

            <div class="row">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th style="font-size: 14px;">#ID</th>
                        <th style="font-size: 14px;">中文名称</th>
                        <th style="font-size: 14px;">英文名称</th>
                        <th style="font-size: 14px;">所属父级</th>
                        <th style="font-size: 14px;">类型</th>
                        <th style="font-size: 14px;">
                            操作
                        </th>
                    </tr>
                    </thead>
                    <tbody>

                    <volist name='nodelist' id='vo'>
                        <tr style="margin-top: 30px; margin-left: 50px;">
                            <td>{$vo.id}</td>
                            <td>
                                <p style="text-indent: {$vo['level']*20}px;">{$vo.title}</p>
                            </td>
                            <td>{$vo.name}</td>
                            <td>{$vo.pid}</td>
                            <td>
                                <if condition="$vo.level eq 1">
                                    <span class="badge badge-inverse">项目</span>
                                    <elseif condition="$vo.level eq 2"/>
                                    <span class="badge badge-info">模块</span>
                                    <else />
                                    <span class="badge badge-important">操作</span>
                                </if>
                            </td>
                            <td class="center">
                                <if condition="$vo.status eq 1">
                                    <button class="btn btn-xs btn-inverse set" value="{$vo.id}">禁用</button>
                                    <else/>
                                    <button class="btn btn-xs btn-primary set" value="{$vo.id}">启用</button>
                                </if>
                                <button class="btn btn-xs btn-danger del" value="{$vo.id}">权限删除</button>
                            </td>
                        </tr>
                    </volist>

                    </tbody>
                </table>
            </div>
        </div><!-- /.page-content -->
    </div><!-- /.main-content -->

    <script src="__ROOT__/Application/Common/Public/js/jquery.validate-1.13.1.js"></script>
    <script type="text/javascript">
        var $URL = "__APP__/Home/AdminNode/";
        $(function(){
            //delete AdminUser
            $(".del").bind('click',function(){
                var $msg = confirm('确认删除该用户吗？删除后不可恢复！');
                var $id = $(this).attr('value');
                var $url = $URL+'delNode';
                if(!$msg){
                    return false;
                }

                $.ajax({
                    url: $url,
                    type: 'get',
                    dataType: 'text',
                    data:{id:$id},
                    success:function($result){
                        if($result){
                            alert('删除成功');
                            window.location.reload();
                        }else{
                            alert('删除失败');
                        }
                    },
                    error:function(){
                        alert('删除失败');
                    }
                });
            });
            //status set
            $(".set").bind('click',function(){
                var $id = $(this).attr('value');
                $.ajax({
                    url: $URL+'setStatus',
                    type: 'get',
                    dataType: 'text',
                    data:{id:$id},
                    success:function($result){
                        if($result){
                            alert('设置成功');
                            window.location.reload();
                        }else{
                            alert('设置失败');
                        }
                    },
                    error:function(){
                        alert('设置失败');
                    }
                });
            });
        });
    </script>
</block>

